export interface AIModelConfig {
  model_name: string;
  model_type: string;
  model_url: string;
  model_token?: string;
  // 本地模型特定配置
  local_config?: {
    context_length?: number;
    temperature?: number;
    max_tokens?: number;
    stream?: boolean;
    keep_alive?: string;
    // Ollama特定配置
    system_prompt?: string;
    // LocalAI特定配置
    backend?: string;
    // 自定义本地模型配置
    custom_headers?: Record<string, string>;
    timeout?: number;
  };
}

export interface AppConfig {
  main_ai_model: string;
  models: Record<string, AIModelConfig>;
}

export interface Message {
  id: string;
  role: 'user' | 'assistant';
  content: string;
  timestamp: Date;
  status: 'sending' | 'sent' | 'error' | 'interrupted';
  // 用于thinking模型的思考内容
  thinkingContent?: string;
  isThinking?: boolean;
  // MCP工具调用相关
  toolCalls?: ToolCall[];
  toolResults?: ToolResult[];
  mcpServerUsed?: string[];
}

export interface ConnectionStatus {
  connected: boolean;
  error?: string;
  retrying: boolean;
}

export interface ThemeConfig {
  userMessage: string;
  aiMessage: string;
  systemMessage: string;
  errorMessage: string;
  codeBlock: string;
  inputArea: string;
}

export interface UIState {
  isTyping: boolean;
  showCursor: boolean;
  inputMode: 'normal' | 'multiline';
}

// MCP相关类型定义
export interface MCPServerConfig {
  command: string;
  args: string[];
  env?: Record<string, string>;
  timeout?: number;
}

export interface MCPConfig {
  mcpServers: Record<string, MCPServerConfig>;
}

export interface ToolCall {
  id: string;
  mcpServer: string;
  toolName: string;
  parameters: Record<string, any>;
  timestamp: Date;
  status: 'pending' | 'completed' | 'failed';
}

export interface ToolResult {
  id: string;
  toolCallId: string;
  result: any;
  timestamp: Date;
  error?: string;
}

export interface ToolUsageStatus {
  mcpServerName: string;
  toolName: string;
  status: 'calling' | 'success' | 'error';
  startTime: Date;
  duration?: number;
  parameters?: Record<string, any>;
  result?: any;
}

// 中断控制相关类型
export interface Interruptible {
  interrupt(reason?: string): Promise<void>;
  isInterrupting(): boolean;
}

export interface InterruptStatus {
  isInterrupting: boolean;
  reason?: string;
  timestamp?: Date;
}

// 日志系统相关类型定义
export type LogLevel = 'ERROR' | 'WARN' | 'INFO' | 'DEBUG';

export interface LogEntry {
  timestamp: Date;
  level: LogLevel;
  source: string;
  message: string;
  data?: any;
}

export interface LogConfig {
  enabled: boolean;
  directory: string;
  rotation: 'hourly' | 'daily';
  level: LogLevel;
  maxFiles: number;
  bufferSize: number;
  enableDebugLog: boolean;
  maxFileSize: number;
  compressionEnabled: boolean;
}

export interface LogRotationInfo {
  currentFile: string;
  nextRotationTime: Date;
  fileHandle?: any;
}

export interface LogBufferItem {
  entry: LogEntry;
  formatted: string;
}

export interface LogMetrics {
  totalEntries: number;
  errorCount: number;
  warnCount: number;
  rotationCount: number;
  lastRotationTime?: Date;
}

export interface ConsoleRedirectOptions {
  preserveConsole: boolean;
  loggerInstance?: any;
}